/* GUI CONVERTED from reoprp01.p (converter v1.76) Thu Dec 20 07:32:12 2001 */
/* reoprp01.p - REPETITIVE OPERATION SCHEDULE                                 */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.7.1.4 $                                                       */
/*V8:ConvertMode=FullGUIReport                                                */
/* REVISION: 5.0      LAST MODIFIED: 07/24/89   BY: emb                       */
/* REVISION: 6.0      LAST MODIFIED: 08/28/90   BY: emb *D040*/
/* REVISION: 6.0      LAST MODIFIED: 10/25/90   BY: SMM *D144*/
/* REVISION: 6.0      LAST MODIFIED: 11/20/90   BY: emb *D223*/
/* REVISION: 6.0      LAST MODIFIED: 08/21/91   BY: bjb *D811*/
/* REVISION: 7.0      LAST MODIFIED: 03/01/92   BY: smm *F230*/
/* REVISION: 7.2      LAST MODIFIED: 12/21/92   BY: emb *G466*/
/* REVISION: 7.2      LAST MODIFIED: 09/30/93   BY: pxd *FJ31*/
/* REVISION: 7.4      LAST MODIFIED: 01/12/94   BY: qzl *H276*/
/* REVISION: 7.4      LAST MODIFIED: 09/12/94   BY: pxd *FR26*/
/* REVISION: 7.4      LAST MODIFIED: 10/07/94   BY: cpp *FR71*/
/* REVISION: 7.4      LAST MODIFIED: 10/18/94   BY: jzs *GN91* */
/* REVISION: 7.4      LAST MODIFIED: 12/28/94   BY: pxd *F0BH* */
/*                    LAST MODIFIED: 01/12/95   BY: cpp *F0DL* */
/* REVISION: 7.3      LAST MODIFIED: 03/01/95   BY: WUG *G0G3**/
/* REVISION: 7.2      LAST MODIFIED: 03/23/95   BY: ais *F0NT*/
/* REVISION: 7.4      LAST MODIFIED: 12/13/95   BY: jym *G1G6*/
/* REVISION: 7.4      LAST MODIFIED: 08/26/96   BY: *G2CL* Julie Milligan     */
/* REVISION: 8.6      LAST MODIFIED: 10/22/97   BY: ays *K14P*                */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 05/11/00   BY: *N08Y* Kaustubh K.        */
/* REVISION: 9.1      LAST MODIFIED: 08/23/00   BY: *N0ND* Mark Brown         */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.7.1.4 $  BY: Jean Miller         DATE: 12/14/01  ECO: *P03Q*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/


/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "b+ "}

define new shared variable start like wr_start no-undo.
define new shared variable interval as integer extent 14 no-undo.
define new shared variable sdate like ro_start extent 14 no-undo.
define new shared variable schedule like wr_qty_ord extent 14
   format "->>>,>>9" no-undo.
define new shared variable complete like wr_qty_ord extent 14
   format "->>>,>>9" no-undo.
define new shared variable open_ref like wr_qty_ord extent 14
   format "->>>,>>9" no-undo.
define new shared variable load as decimal extent 14
   format "->>>,>>9" no-undo.

define new shared variable disp_schedule as character extent 14.
define new shared variable disp_complete as character extent 14.
define new shared variable disp_open_ref as character extent 14.
define new shared variable scale_factor as decimal.
define new shared variable footer_msg as character format "x(56)".

define variable disp_frmt_units_thous like mfc_logical
   label "Quantity Format (Thousands/Units)"
   format "Thousands/Units" no-undo.

define new shared variable workdays as integer extent 14
   format "->>>,>>9" no-undo.
define variable holiday as integer no-undo.
define variable i as integer no-undo.
define variable j as integer no-undo.
define variable qty like wo_qty_ord no-undo.
define variable wostart as integer no-undo.

define new shared variable nonwdays as decimal no-undo.

define variable elapsedays as integer no-undo.
define variable wdays as integer no-undo.

define new shared variable overlap as integer no-undo.
define variable wointerval as integer no-undo.
define variable lead as integer no-undo.

define new shared variable num_intervals as integer initial 13 no-undo.
define new shared variable monthend as integer no-undo.

define variable site like wo_site no-undo.
define new shared variable worouting like wo_routing no-undo.
define variable site1 like wo_site no-undo.

define new shared variable wosite like wo_site no-undo.
define variable part like wr_part no-undo.
define variable part1 like wr_part no-undo.
define variable op like wr_op format ">>>>>>" no-undo.
define variable op1 like op no-undo.
define variable wkctr like wc_wkctr no-undo.
define variable wkctr1 like wc_wkctr no-undo.
define variable mch like wc_mch no-undo.
define variable mch1 like wc_mch no-undo.
define variable dept like wc_dept no-undo.
define variable dept1 like wc_dept no-undo.

define variable dptdesc like dpt_desc no-undo.

define new shared variable more like mfc_logical  no-undo.
define variable old_start as date no-undo.

define new shared variable ending like ro_end no-undo.
define new shared variable dwm as character format "!(1)"
   label "Day/Week/Month" no-undo.
define new shared variable idays as integer format ">>>>>9"
   label "Per Column" no-undo.

define new shared variable wrop like wr_op no-undo.

define new shared variable wrpart like wr_part no-undo.
define new shared variable wo_recno as recid.
define new shared variable wr_recno as recid.
define variable prline like rps_line.
define variable prline1 like rps_line.
define new shared variable woline  like wo_line no-undo.
define variable woparts like wo_part.
define new shared variable prt_op_hdr like mfc_logical no-undo.

define variable include_nonmilestone like mfc_logical
   label "Include Nonmilestone Operations".
define variable l_msgdesc like msg_desc no-undo.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
part     colon 20 part1     label "To" colon 49
   site     colon 20 site1     label "To" colon 49
   prline   colon 20 prline1   label "To" colon 49
   op       colon 20 op1       label "To" colon 49
   skip(1)
   start    colon 20
   ending   colon 20
   dwm      colon 20
   idays    colon 20
   disp_frmt_units_thous colon 38
   include_nonmilestone        colon 38
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

FORM /*GUI*/  header
   footer_msg
with STREAM-IO /*GUI*/  frame footer page-bottom no-labels width 132 no-attr-space.

/* PRE-SET DISPLAY FORMAT TO UNITS */
disp_frmt_units_thous = false.

{wbrp01.i}

/* *** NOTE: QUANTITIES DISPLAYED IN THOUSANDS (1000'S) *** */
{pxmsg.i &MSGNUM=3815 &ERRORLEVEL=1 &MSGBUFFER=l_msgdesc}


/*GUI*/ {mfguirpa.i true "printer" 132 " " " " " "  }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:


   start = old_start.

   if start = ? then start = today.
   if dwm = "" then dwm = "W".
   if idays = 0 or idays = ? then idays = 1.

   if part1   = hi_char then part1 = "".
   if site1   = hi_char then site1 = "".
   if prline1 = hi_char then prline1 = "".
   if wkctr1  = hi_char then wkctr1 = "".
   if mch1    = hi_char then mch1 = "".
   if dept1   = hi_char then dept1 = "".

   if c-application-mode <> 'web' then
   
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


   {wbrp06.i &command = update
      &fields = "  part part1  site site1  prline prline1 op op1
                   start ending dwm idays  disp_frmt_units_thous
                   include_nonmilestone"
      &frm = "a"}

   if (c-application-mode <> 'web') or
      (c-application-mode = 'web' and
      (c-web-request begins 'data'))
   then do:

      if start < today then do:
         /* START DATE IS BEFORE TODAY.*/
         {pxmsg.i &MSGNUM=15 &ERRORLEVEL=2}
      end.

      /* CREATE BATCH INPUT STRING */
      bcdparm = "".

      {mfquoter.i part   }
      {mfquoter.i part1  }
      {mfquoter.i site   }
      {mfquoter.i site1  }
      {mfquoter.i prline }
      {mfquoter.i prline1 }
      {mfquoter.i op     }
      {mfquoter.i op1    }
      {mfquoter.i start  }
      {mfquoter.i ending }
      {mfquoter.i dwm    }
      {mfquoter.i idays  }
      {mfquoter.i disp_frmt_units_thous }
      {mfquoter.i include_nonmilestone}

      if part1 = ""  then part1 = hi_char.
      if site1 = ""  then site1 = hi_char.
      if prline1 = "" then prline1 = hi_char.

      if wkctr1 = "" then wkctr1 = hi_char.
      if mch1   = "" then mch1 = hi_char.
      if dept1  = "" then dept1 = hi_char.

      if index("dwmp",dwm) = 0 then do:
         /* INTERVAL MUST BE (D)ay (W)eek OR (M)onth. */
         {pxmsg.i &MSGNUM=14 &ERRORLEVEL=3}
         if c-application-mode = 'web' then return.
         else /*GUI NEXT-PROMPT removed */
         /*GUI UNDO removed */ RETURN ERROR.
      end.

   end.

   /* OUTPUT DESTINATION SELECTION */
   
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i "printer" 132 " " " " " " " " }
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:



   {mfphead.i}

   if disp_frmt_units_thous     /* TRUE= THOUSANDS */
   then do:
      footer_msg = l_msgdesc.
      scale_factor = 1000.
   end.
   else do:
      footer_msg = " ".
      scale_factor = 1.
   end.

   assign
      old_start = start
      woparts = ?
      woline = "".

   woloop:
   for each wo_mstr no-lock where
         wo_part >= part and wo_part <= part1
     and wo_site >= site and wo_site <= site1
     and wo_line >=  prline and wo_line <=  prline1
     and wo_type = "S"
     and wo_status <> "C"
   by wo_part by wo_site by wo_line by wo_routing:

      wrpart = wo_part.

      if woline = wo_line and woparts = wo_part and wosite = wo_site
         and worouting = wo_routing
      then
         next woloop.

      else do:
         assign
            woparts = wo_part
            woline = wo_line
            wosite = wo_site
            worouting = wo_routing.
      end.

      find first wr_route no-lock where
             wr_part = wo_part
         and wr_op >= op
         and (wr_op <= op1 or op1 = 0)
         and (include_nonmilestone or wr_milestone)
         and wr_lot = wo_lot
      use-index wr_lot no-error.

      repeat:

         if not available wr_route then next woloop.

         wrop = wr_op.
         wrpart = wr_part.

         start = old_start.
         prt_op_hdr = yes.      /*ITS TIME TO PRINT OP HEADER LINES*/

         /* CALCULATE LOAD IN EACH PERIOD  */
         wo_recno = recid(wo_mstr).
         wr_recno = recid(wr_route).

         {gprun.i ""reoprp1a.p""}

         
/*GUI*/ {mfguirex.i  "false"} /*Replace mfrpexit*/


         find first wr_route no-lock where
                wr_part = wrpart
            and wr_op > wrop
            and (wr_op <= op1 or op1 = 0)
            and (include_nonmilestone or wr_milestone)
            and wr_lot = wo_lot
         use-index wr_lot no-error.

      end.

      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


   end.

   
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


end.

{wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" part part1 site site1 prline prline1 op op1 start ending dwm idays disp_frmt_units_thous include_nonmilestone "} /*Drive the Report*/
